import { accessibility, config } from '@kit.AccessibilityKit';
import { BusinessError } from '@kit.BasicServicesKit';
import Want from '@ohos.app.ability.Want';
import Logger from '../utils/Logger'

let TAG = "_:[AE config]"
let name: string = 'ohos.samples.harmonyagent/AccessibilityExtAbility';
let capability: accessibility.Capability[] = [
  "retrieve",
  "gesture",
  "keyEventObserver",
  "touchGuide"
];

export function enableAEA() {
  try {
    config.shortkeyTarget.set(name)
    console.info(TAG, `Succeeded in set shortkeyTarget value is ${name}`);
  } catch (err) {
    console.error(TAG, `failed to set shortkeyTarget, Code is ${err.code}, message is ${err.message}`);
  }
  try {
    config.shortkey.set(true)
    console.info(TAG, `Succeeded in set shortKey value is true`);
  } catch (err) {
    console.error(TAG, `failed to set shortKey, Code is ${err.code}, message is ${err.message}`);
  }
}

export function startAEA() {
  try {
    config.enableAbility(name, capability)
    console.info(TAG, `Succeeded  in enable ability, name is ${name}, capability is ${capability}`);
  } catch (err) {
    console.error(TAG, `failed to enable ability, Code is ${err.code}, message is ${err.message}`);
  }
}

export function stopAEA() {
  try {
    config.disableAbility(name)
    console.info(TAG, `Succeeded  in disable ability, name is ${name}, capability is ${capability}`);
  } catch (err) {
    console.error(TAG, `failed to disable ability, Code is ${err.code}, message is ${err.message}`);
  }
}
